import { Column, Entity, Index } from 'typeorm'
import { BaseEntity } from './BaseEntity'
import { ApiProperty } from '@nestjs/swagger'
import { IsString, IsInt, IsDefined, Length, MaxLength, IsNotEmpty, IsEmpty, Min, Max } from 'class-validator'

@Entity('t_project')
export default class ProjectEntiy extends BaseEntity {
  @Column({
    comment: '项目名',
    length: 200,
  })
  @ApiProperty({ description: '项目名', maxLength: 200 })
  @IsDefined({ message: '项目名必填' })
  @IsNotEmpty({ message: '项目名必填' })
  @MaxLength(200, { message: '项目名最多200字符' })
  name: string

  @Column({
    comment: '唯一标识',
    length: 200,
    unique: true,
  })
  @ApiProperty({ description: '唯一标识', maxLength: 200, uniqueItems: true })
  @IsDefined({ message: '唯一标识必填' })
  @IsNotEmpty({ message: '唯一标识必填' })
  @MaxLength(200, { message: '唯一标识最多200字符' })
  flag: string

  @Column({
    comment: '是否启用(启用: 1, 禁用: 0)',
    type: 'tinyint',
  })
  @ApiProperty({ description: '是否启用', enum: [1, 0] })
  @IsDefined({ message: '是否启用必填' })
  @Min(0, { message: '启用: 1, 禁用: 0' })
  @Max(1, { message: '启用: 1, 禁用: 0' })
  enable: number

  @Column({
    comment: '备注',
    type: 'text',
  })
  @ApiProperty({ description: '备注', required: false })
  @MaxLength(500, { message: '备注最多500字符' })
  remark: string
}
